<!--
 * @Author: suo
 * @Date: 2020-08-12 18:31:29
 * @LastEditTime: 2020-08-21 11:27:35
 * @LastEditors: suo
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>test</title>
</head>

<body>
	<script src="../dist/itools.js"></script>
	<script>
		// cookie
		iTools.cookie.set('name1', 'shb', 3600)
		iTools.cookie.set('name', 'shb', 3600)
		let name = iTools.cookie.get('name1')
		console.log(name)
		// iTools.cookie.del('name')
		// clone
		let obj_a = { a: 1 }
		let obj_b = iTools.clone(obj_a)
		obj_a.a = 2
		console.log(obj_a, obj_b)
		// download
		let filename = '当前页面'
		let filePath = window.location.href
		// iTools.download(filename, filePath)
		// getParam
		let name2 = iTools.getParam('name')
		let age = iTools.getParam('age', 'https://suohb.com?age=18')
		console.log(name2, age)
		// randomStr
		let str = iTools.randomStr(10)
		let str2 = iTools.randomStr(9, 'letter')
		let str3 = iTools.randomStr(8, 'number')
		console.log(str, str2, str3)
		// type
		console.log(iTools.type('str'))
		console.log(iTools.type(124))
		console.log(iTools.type(true))
		console.log(iTools.type(null))
		console.log(iTools.type([1, 2, 3]))
		console.log(iTools.type(() => { }))
		console.log(iTools.type({ a: 1 }))
		console.log(iTools.type(new Date()))
		console.log(iTools.type(undefined))
		// uniqueId
		console.log(iTools.uniqueId())
		console.log(iTools.uniqueId())
		// debounce
		function logPos(e) {
			console.log(e.pageX, e.pageY)
		}
		// document.addEventListener('mousemove', iTools.debounce(logPos, 500))
		// throttle
		document.addEventListener('mousemove', iTools.throttle(logPos, 500))

		// trim
		let str4 = ' aa '
		let arr = [' aa ', ' bb ']
		let obj = { a: ' aa ', b: [' bb  '] }
		console.log(iTools.trim(str4))
		console.log(iTools.trim(arr))
		console.log(iTools.trim(obj))
		// once
		let objOnce = {
			name: 'once',
			getName(value) {
				console.log(this.name, value)
			}
		}
		let objOnce2 = {
			name: 'once2'
		}
		let onceFn = iTools.once(objOnce.getName, objOnce2)
		onceFn(1)
		onceFn(2)
	</script>
</body>

</html>